package com.ly.jdk8.time;
import	java.time.temporal.ChronoUnit;

import java.time.*;

/**
 * @Classname TestLocalDateTime
 * @Description TODO
 * @Date 2020/9/30 9:52
 * @Author 冷心影翼
 */
public class TestLocalDateTime {

	public static void main(String[] args) {

		LocalDateTime now = LocalDateTime.now();
		LocalDate localDate = LocalDate.now();
		LocalTime localTime = LocalTime.now();
		System.out.println(now);
		System.out.println(localDate);
		System.out.println(localTime);
		LocalDateTime localDateTime = now.plusDays(7);
		System.out.println(localDateTime);
		System.out.println(localDateTime.minusMonths(2));
		System.out.println("----------");

		Instant instant = Instant.now();
		System.out.println(instant);
		System.out.println(instant.atOffset(ZoneOffset.ofHours(8)));
		System.out.println(instant.toEpochMilli());
		System.out.println("--------------");

		Duration duration = Duration.between(instant,instant.plus(7, ChronoUnit.DAYS));
		System.out.println(duration.getUnits());
		System.out.println(Duration.between(LocalDateTime.now(), LocalDateTime.now().minusDays(7)).toHours());
		System.out.println("--------------");

		LocalDate t1 = LocalDate.of(2000, 6, 20);
		LocalDate t2 = LocalDate.now();
		Period period = Period.between(t1,t2);
		System.out.println(period);
	}


}


